From: Jan Beulich Date: Tue, 18 Feb 2020 15:24:24 +0000 (+0100) Subject: x86/MCFG: fix off-by-one in E820 check X-Git-Tag: archive/raspbian/4.14.0+80-gd101b417b7-1+rpi1^2~63^2~681 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22?a=commitdiff_plain;h=a5dccdd86651f6d7eb0c2b9fb0347a4e770184ff;p=xen.git x86/MCFG: fix off-by-one in E820 check Also adjust the comment ahead of e820_all_mapped() to clarify that the range is not inclusive at its end. Reported-by: Roger Pau Monné Signed-off-by: Jan Beulich Reviewed-by: Wei Liu Reviewed-by: Roger Pau Monné --- diff --git a/xen/arch/x86/e820.c b/xen/arch/x86/e820.c index c9dc52c768..aa602773bb 100644 --- a/xen/arch/x86/e820.c +++ b/xen/arch/x86/e820.c @@ -38,7 +38,7 @@ struct e820map e820; struct e820map __initdata e820_raw; /* - * This function checks if the entire range is mapped with type. + * This function checks if the entire range [start,end) is mapped with type. * * Note: this function only works correct if the e820 table is sorted and * not-overlapping, which is the case @@ -56,7 +56,8 @@ int __init e820_all_mapped(u64 start, u64 end, unsigned type) if (ei->addr >= end || ei->addr + ei->size <= start) continue; - /* if the region is at the beginning of we move + /* + * If the region is at the beginning of [start,end) we move * start to the end of the region since it's ok until there */ if (ei->addr <= start) diff --git a/xen/arch/x86/x86_64/mmconfig-shared.c b/xen/arch/x86/x86_64/mmconfig-shared.c index 0c55c7206e..7c3ed64b4c 100644 --- a/xen/arch/x86/x86_64/mmconfig-shared.c +++ b/xen/arch/x86/x86_64/mmconfig-shared.c @@ -337,7 +337,7 @@ static int __init is_mmconf_reserved( u64 old_size = size; int valid = 0; - while (!e820_all_mapped(addr, addr + size - 1, E820_RESERVED)) { + while (!e820_all_mapped(addr, addr + size, E820_RESERVED)) { size >>= 1; if (size < (16UL<<20)) break;